package com.qidian.mes.md.controller;

import com.qidian.mes.md.service.MdWorkService;
import com.qidian.mes.util.pojo.QdResult;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 小可怎么都睡不够
 * @Description:
 * @Time: 2024-04-10 19:03
 **/
@RestController
@RequestMapping("/work")
@CrossOrigin
public class MdWorkController {
    @Autowired
    private MdWorkService mdWorkService;

    //分页查询所有工作站信息
    @GetMapping("/query")
    public QdResult getMdWorksByName(@RequestParam Integer idWorkshop,@RequestParam Integer idProgress,@RequestParam String name, @RequestParam Integer page, @RequestParam Integer limit) {
        return mdWorkService.getMdWorksByName(idWorkshop,idProgress,name,(page-1)*limit,limit);
    }


    //更新工作站信息
    @PutMapping("/update")
    public QdResult updateWork(@RequestBody String data){
        return mdWorkService.updateMdWork(data);
    }
    //添加工作站信息
    @PostMapping("/add")
    public QdResult insertWork(@RequestBody String data){
        return mdWorkService.insertMdWork(data);
    }
    //删除工作站信息
    @DeleteMapping("/{id}")
    public QdResult deleteMdWorkById(@PathVariable(value = "id") Integer idWork) {
        return mdWorkService.deleteMdWorkById(idWork);
    }
    //批量删除
    @DeleteMapping("/del/mall")
    public QdResult deletes(@RequestBody Integer[] idWorks) {
        return mdWorkService.deleteMall(idWorks);
    }

    //获取工作站数量
    @GetMapping("/count")
    public QdResult getCount() {
        return mdWorkService.getCount();
    }


}
